//
//  JWTree.h
//  KotH
//
//  Created by James Weatherley on 16/08/2008.
//  Copyright 2008 James Weatherley. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "JWEntity.h"
#import "../env/vector.h"


@class JWSquare;

typedef vec3_t treeface_t[3];

typedef struct TreeFaces {
	treeface_t face0;
	treeface_t face1;
	treeface_t face2;
	treeface_t face3;
} TreeFaces;

@interface JWTree : NSObject <JWEntity> {

	JWSquare* square;
	BOOL selected;
	
	vec3_t treeVertices[4];
	vec3_t treeNormals[4];
	vec3_t trunkVertices[8];
	vec3_t trunkNormals[4];
	
	treeface_t treeFaces[4];
}

@property (readwrite) BOOL selected;
@property (readonly) JWSquare* square;

-(BOOL)valid;

-(BOOL)intersectWithRayFrom:(const vec3_t)point direction:(const vec3_t)dir;

-(void)calculateTreeGeometry;
//-(void)getTreeGeometryVertices:(vec3_t[])vertices normals:(vec3_t[])normals count:(NSUInteger)count;

-(vec3_t*)treeNormals;
-(vec3_t*)treeVertices;
-(vec3_t*)trunkNormals;
-(vec3_t*)trunkVertices;

@end
